<template>
  <div class="qaview zindexV">
    <el-card class="cardstle card-out" v-loading="loading" element-loading-text="导出中...">
      <el-col :span="13">
        <ShrinkingBox
            ref="shrikingBox"
            @chartSelect="changeCharts"
            @dropChange="dropChangeAct"
            @actionItemSelect="changeActItem"
            :analysisEchcartsFlag="analysisEchcartsFlag"
        >
        </ShrinkingBox>
      </el-col>
      <div v-show="!analysisFlag">
        <el-row class="contentview mgb7" style="display: flex;justify-items: center;align-items: center">
          <div style="width: .03rem;height:.03rem;border-radius: 100%;background: #3164EC;margin-right: .04rem"></div>
          <div>数据源表：</div>
          <div style="font-weight: 500">{{ myDataSource.model ? myDataSource.model.modelName : '' }}</div>
        </el-row>

        <el-row class="contentview mgb7" v-if="conditionDes" >
          <el-col class="f13" :span="3.5" style="display: flex;align-items: center" >
            <div style="width: .03rem;height:.03rem;border-radius: 100%;background: #19C0CB;margin-right: .04rem"></div>
            <div>筛选条件：</div>
          </el-col>
          <el-col class="f13" :span="20">
            <span class="f13 bkcolor" v-show="!flag1">
              {{ conditionDes }}
            </span>
            <el-icon class="editview" @click="flag1 = !flag1" v-show="!flag1">
              <EditPen />
            </el-icon>
            <div v-show="flag1">
              <PopoverComp
                      ref="popoverCompRef"
                      :conditionItem="item"
                      :condition="myDataSource.condition"
                      :firstOptions="allOption"
                      :tname="translateTname(item)"
                      :sIndex="dindex"
                      :key="dindex"
                      :tableId="myDataSource.model.modelId"
                      v-if="myDataSource.condition"
                      v-for="(item, dindex) in myDataSource.condition"
                      @changeConditionItem="conditionEdit"
                      @closeOtherPo="closeOtherPo"
              ></PopoverComp>
              <PopoverComp
                      ref="popoverCompAddRef"
                      tname="新增"
                      :firstOptions="allOption"
                      :condition="myDataSource.condition"
                      :tableId="myDataSource.model.modelId"
                      @addConditionData="addConditionEdit"
                      @closeOtherPo="closeOtherPo"
              ></PopoverComp>
            </div>
          </el-col>
        </el-row>
        <el-row class="contentview mgb7" v-if="columnDes" >
          <el-col class="f13" :span="3.5" style="display: flex;align-items: center" >
            <div style="width: .03rem;height:.03rem;border-radius: 100%;background: #40C84C;margin-right: .04rem"></div>
            <div>统计指标：</div>
          </el-col>
          <el-col class="f13" :span="20.5">
          <span class="f13 bkcolor" v-show="!flag2">
            {{ columnDes }}
          </span>
            <el-icon class="editview" @click="flag2 = !flag2" v-show="!flag2">
              <EditPen />
            </el-icon>

            <div v-show="flag2" style="flex-wrap: wrap; justify-content: flex-start; align-items: baseline;">
              <OnePopoverComp
                      :tname="item.fieldName"
                      :ctag="tindex"
                      :key="tindex"
                      :firstOptions="allOption"
                      v-for="(item, tindex) in myDataSource.column"
                      @editData="statisticalEdit"
                      @deleteItem="deleteSondition"
              >
              </OnePopoverComp>

              <OnePopoverComp
                      tname="新增"
                      :firstOptions="allOption"
                      @editData="statisticalEdit"
              ></OnePopoverComp>
            </div>
          </el-col>
        </el-row>
        <el-row class="contentview mgb7" v-if="groupbyDes" style="display: none">
          <el-col class="f13" :span="3.5" style="display: flex;align-items: center" >
            <div style="width: .03rem;height:.03rem;border-radius: 100%;background: #F99E44;margin-right: .04rem"></div>
            <div>分组规则：</div>
          </el-col>
          <el-col class="f13" :span="20.5">
          <span class="f13 bkcolor" v-show="!flag3">
            {{ groupbyDes }}
          </span>

            <!-- <i
              class="el-icon-edit editview"
              @click="flag3 = !flag3"
              v-show="!flag3"
            ></i> -->

            <!-- <div v-show="flag3">
              <PopoverComp
                :tname="item.dataName"
                v-for="(item, index) in datasrule"
                :key="index"
              ></PopoverComp>
              <PopoverComp tname="新增"></PopoverComp>
            </div> -->
          </el-col>
        </el-row>
        <el-row class="contentview mgb7" v-if="sortDes" style="display: none;align-items: center">
          <el-col class="f13" :span="3.5" style="display: flex;align-items: center" >
            <div style="width: .03rem;height:.03rem;border-radius: 100%;background: #FB757A;margin-right: .04rem"></div>
            <div>排序规则：</div>
          </el-col>
          <el-col class="f13" :span="20.5">
          <span class="f13 bkcolor" v-show="!flag4">
            {{ sortDes }}
          </span>

            <!-- <i class="el-icon-edit editview" @click="flag4 = !flag4" v-show="!flag4"></i> -->
            <el-icon class="editview" @click="flag4 = !flag4" v-show="!flag4">
              <EditPen />
            </el-icon>

            <div v-show="flag4">
              <el-popover
                      placement="bottom"
                      width="200"
                      trigger="click"
                      filterable
                      v-for="(itemObj, index) in myDataSource.sort"
                      :key="index"
              >
                <el-col :span="24">
                  <el-select v-model="itemObj.sortType" placeholder="请选择">
                    <el-option
                            v-for="item in sortOptions"
                            :key="item.fieldCode"
                            :label="item.fieldName"
                            :value="item.fieldCode"
                    >
                    </el-option>
                  </el-select>
                </el-col>
                <el-button slot="reference" class="btnview"
                ><span class="f13">{{ itemObj.fieldShowName }}</span
                ><span class="f13">{{ transASC(itemObj.sortType) }}</span>
                </el-button>
              </el-popover>
            </div>
          </el-col>
        </el-row>
        <el-row v-show="flag1 || flag2 || flag3 || flag4" class="edituplview">
          <el-button type="primary" plain @click="saveEdit">确定</el-button>
          <el-button plain @click="cancleEdit">取消</el-button>
        </el-row>
        <el-row v-show="!(flag1 || flag2 || flag3 || flag4)">
          <div v-if="quickCondition" style="display: flex;align-items: center;justify-content: flex-end;width: 100%;margin-bottom: .05rem">
            <div v-if="quickCondition.fieldCode && quickCondition.fieldCode.startsWith('MONTH_ID')" style="display: flex;align-items: center">
              <div>{{quickCondition.fieldName}}：</div>
              <el-date-picker
                  v-if="!quickCondition.isArr&&quickCondition.whereType!='IN'"
                  v-model="quickCondition.whereValue"
                  format="YYYYMM"
                  value-format="YYYYMM"
                  type="month"
                  placeholder="选择日期"
                  @change="quickEmitData"
                  :disabled-date="quickCondition.disabledDate"
              />
              <el-date-picker
                  v-else-if="quickCondition.isArr&&quickCondition.whereType!='IN'"
                  v-model="quickCondition.whereValue"
                  type="monthrange"
                  unlink-panels
                  range-separator="至"
                  start-placeholder="开始时间"
                  end-placeholder="结束时间"
                  @change="quickEmitData"
                  :disabled-date="quickCondition.disabledDate"
              />
              <el-date-picker
                  v-else-if="quickCondition.whereType=='IN'"
                  v-model="quickCondition.whereValue"
                  type="monthrange"
                  unlink-panels
                  range-separator="至"
                  start-placeholder="开始时间"
                  end-placeholder="结束时间"
                  @change="quickEmitData"
                  :disabled-date="quickCondition.disabledDate"
              />
            </div>
            <div v-if="quickCondition.fieldCode && quickCondition.fieldCode.startsWith('DAY_ID')" style="display: flex;align-items: center">
              <div>{{quickCondition.fieldName}}：</div>
              <el-date-picker
                  v-if="!quickCondition.isArr&&quickCondition.whereType!='IN'"
                  v-model="quickCondition.whereValue"
                  type="date"
                  placeholder="选择日期"
                  format="YYYYMMDD"
                  value-format="YYYYMMDD"
                  @change="quickEmitData"
                  :disabled-date="quickCondition.disabledDate"
              >
              </el-date-picker>
              <el-date-picker
                  v-else-if="quickCondition.isArr&&quickCondition.whereType!='IN'"
                  v-model="quickCondition.whereValue"
                  type="daterange"
                  unlink-panels
                  range-separator="至"
                  start-placeholder="开始时间"
                  end-placeholder="结束时间"
                  @change="quickEmitData"
                  :disabled-date="quickCondition.disabledDate"
              />
              <el-date-picker
                  v-else-if="quickCondition.whereType=='IN'"
                  v-model="quickCondition.whereValue"
                  type="daterange"
                  unlink-panels
                  range-separator="至"
                  start-placeholder="开始时间"
                  end-placeholder="结束时间"
                  @change="quickEmitData"
                  :disabled-date="quickCondition.disabledDate"
              />
            </div>
          </div>
        </el-row>
        <el-row v-show="!(flag1 || flag2 || flag3 || flag4)">
          <echart-bi
                  v-loading="tab_loading"
                  element-loading-text="数据加载中..."
                  v-if="chartDataResult.data && chartDataResult.data.length > 0"
                  ref="charRef"
                  :chartType="chType"
                  :chartData="chartDataResult"
                  :sumCol="sumCol"
                  :units="units"
                  :fieldcolumns="fieldcolumns"
                  @backFun="callback"
          ></echart-bi>
          <span v-else class="f13 grayc bkcolor">该账期数据暂未发布，试试换成其他账期数据。
            <span v-if="myDataSource.maxPeriod">
              您可以点<span style="color: #5C7CFF;margin-left:5px;cursor: pointer" @click="newQuestion(myDataSource.maxPeriodFormat)"> {{myDataSource.maxPeriodFormat}} </span>，
              或在下拉框中选择<span style="margin-left:5px;"> {{myDataSource.maxPeriodFormat}} </span>，查询最新账期数据。
            </span>
          </span>
        </el-row>
      </div>
      <!--智能归因-->
      <div v-show="analysisFlag" class="zngy-wrap">
        <div class="zngy_div">
          <img src="@/assets/images/suspension/zngy.png" style="width: .12rem;margin-right: .05rem"/>
          <span>智能归因</span>
          <audio ref="audioPlayer" controls class="zngy-wrap" preload="none"
                 style="margin-right: .05rem;margin-left: .05rem;    height: 30px;">
            <source :src="audioUrl" />
          </audio>
<!--
          <el-button type="primary" size="small" @click="changeVoice(2)">女音播放</el-button>
          <el-button type="primary" size="small" @click="changeVoice(1)">男音播放</el-button>
-->
        </div>
        <el-row class="contentview mgb7">
          <el-col :span="24" class="f13 bkcolor">
            {{ lsText }}
          </el-col>
        </el-row>
        <el-row>
          <div :id="'echartsAnalysis_'+uuid">
          </div>
        </el-row>
      </div>
      <WatchSql ref="watchsqlref" @exeSqlAct="watchSqlExe"></WatchSql>
      <SuggestComp ref="suggestcompref" :logSessionId="logSessionId"></SuggestComp>
      <watchUse ref="watchuseref"></watchUse>
    </el-card>
    <!---指标关联报表--->
    <div v-if="pcReportUrls.length>0" class="card-wrap" id="div1">
      <div class="other-wrap">指标关联报表：</div>
      <div style="display: flex;flex-wrap: wrap;">
        <!--<a v-for="item in pcReportUrls" :key="item.name" class="a-wrap" :href="item.url" target="_blank">{{item.name}}</a>-->
        <a v-for="item in pcReportUrls" :key="item.name" class="a-wrap" @click="redirectUrl(item)">
          <img src="@/assets/images/suspension/icon-bb.png" style="height: 18px">&nbsp;
          {{item.name}}
        </a>
      </div>
    </div>
    <!---您可以继续问我--->
    <div v-if="fuzzyTexts.length>0" class="card-wrap" id="div2">
      <div class="other-wrap">您可以继续问我：</div>
      <div style="display: flex;flex-wrap: wrap;">
        <a v-for="(item,index) in fuzzyTexts" :key="item" class="a-wrap" @click="newQuestion(item)">
          <img v-if="index===0" src="@/assets/images/suspension/qu0.png" style="height: 18px">&nbsp;
          <img v-else-if="index===1" src="@/assets/images/suspension/qu1.png" style="height: 18px">&nbsp;
          <img v-else-if="index===2" src="@/assets/images/suspension/qu2.png" style="height: 18px">&nbsp;
          {{item}}
        </a>
      </div>
    </div>
  </div>
</template>

<script>
import ShrinkingBox from './ShrinkingBox.vue'
import PopoverComp from './PopoverComp.vue'
import OnePopoverComp from './OnePopoverComp.vue'
import EchartBi from './EchartBi.vue'
import WatchSql from './WatchSql.vue'
import { transCodeToStr } from './util.js'
import { getDataFromTb, getValFromSQL, postSqlFromSQL, getRedirectUrl, getAssembleAnalysis,saveEvaluateInfo,getVoiceFromtext } from '@/api/chartdb'
import SuggestComp from './SuggestComp.vue'
import { ElMessage } from 'element-plus'
import * as XLSX from 'xlsx'
import FileSaver from 'file-saver' //下载exxel
import WatchUse from './UseSuggest.vue'
import $ from 'jquery'
import consts from '../../common/consts'
import * as echarts from 'echarts'
import {v4 as uuidv4} from 'uuid';
import { randNm, dateFormat } from '@/common/util'
import moment from 'moment'
import iconpg from '../../assets/images/web_tab_bg.png'
export default {
  setup() {
    //动态加载css
    let cssPath="";
    let mode=localStorage.getItem("mode")
    if(mode=="dark"){
      cssPath = import("/src/assets/css/dark/index.scss");
    }else if(mode=="light"){
      cssPath = import("/src/assets/css/light/index.scss");
    }
    return {
      cssPath
    };
  },
  props: {
    dataSource: {
      type: Object
    },
    dTime: {
      type: String,
      default: ''
    },
    orgsObj: {
      type: Object
    },
    sessionID: {
      type: String
    },
    isClick: {
      type: Boolean
    },
    logSessionId:{
      type: String
    }
  },
  components: {
    ShrinkingBox,
    PopoverComp,
    EchartBi,
    WatchSql,
    OnePopoverComp,
    SuggestComp,
    WatchUse
  },
  data() {
    return {
      loading:false,
      tab_loading:false,
      myDataSource: {}, //缓存数据
      flag1: false,
      flag2: false,
      flag3: false,
      flag4: false,
      chType: 'table',
      conditionDes: '', //取数条件描述
      columnDes: '', //统计指标描述
      groupbyDes: '', //分组规则描述
      sortDes: '', //排序规则描述
      sumCol:[],//计算合计值列 目前filedClass=1时计算
      chartDataResult: {}, //表格数据
      exportReult:'',
      allOption: [], //所有元数据数组
      fiterOption: [], //元数据数组
      wValue: '', //存放值
      pcReportUrls: [],//相关指标数据
      fuzzyTexts:[],
      indicatorTexts:[],
      progressValue: 0, // 初始化进度值为0%
      sortOptions: [
        { fieldCode: 'ASC', fieldName: '升序' },
        { fieldCode: 'DESC', fieldName: '降序' }
      ],
      currentSql: '',
      level_list_option:consts.level_list_option,
      level_list_option_1:consts.level_list_option_1,
      units:{},
      fieldcolumns:{},
      dataAnalysis:{},
      nextValList:[],
      nextHbValList:[],
      analysisFlag:false,
      analysisEchcartsFlag:false,
      uuid:uuidv4(),
      lsText:"",
      myChart:"",
      quickConditions:[],
      quickCondition:{},
      audioUrl:"",
      audioSex:"",
      isAudioPlaying: false, // 当前音频播放状态
      lastTime: 0, // 上一次音频播放的时间
      shouldEmit: false, // 是否需要发出状态改变事件
      lastEmittedStatus: null, // 用于记录上一次发出的状态
    }
  },
  mounted() {
    this.myDataSource = { ...this.dataSource }
    this.reflashDataSource()
    //查询表元数据
    this.queryTableValueAc()
    this.assembleAnalysis()

    this.$refs.audioPlayer.addEventListener('timeupdate', this.checkPlaying);
    this.$refs.audioPlayer.addEventListener('play', this.handlePlay);
    this.$refs.audioPlayer.addEventListener('pause', this.handlePause);
  },
  watch: {
    exportReult(newIndex, oldIndex) {
      this.exportReult=""
      this.loading=false
    },
  },
  methods: {
    newMessage(phySql){
      this.$emit("sendFbMessage",phySql)
    },
    checkPlaying(event) {
      const isCurrentlyPlaying = !this.$refs.audioPlayer.paused;
      const currentTime = this.$refs.audioPlayer.currentTime;

      // 更新当前播放状态
      this.isAudioPlaying = isCurrentlyPlaying;
      this.lastTime = currentTime;

      // 判断是否需要发出状态改变事件
      if (isCurrentlyPlaying && (this.lastEmittedStatus === null || this.lastEmittedStatus !== isCurrentlyPlaying)) {
        // 如果音频正在播放，并且上次的状态是null或者与当前状态不一致
        this.shouldEmit = true;
      } else if (!isCurrentlyPlaying && this.lastEmittedStatus === true) {
        // 如果音频不在播放，并且上次发出的状态是true（即上次认为在播放）
        this.shouldEmit = true;
      }else {
        // 如果当前播放状态与上次发出的状态一致，则不需要发出事件
        this.shouldEmit = false;
      }

      // 更新上一次发出的状态
      this.lastEmittedStatus = isCurrentlyPlaying;

      // 如果需要发出事件，调用emit方法
      if (this.shouldEmit) {
        this.$emit('changePlayAudioStatus', this.isAudioPlaying);
      }
    },
    handlePlay() {
      // 当音频开始播放时，更新状态
      this.isAudioPlaying = true;
    },
    handlePause() {
      // 当音频暂停时，更新状态
      this.isAudioPlaying = false;
    },

    async changeVoice(audioSex) {
      if(this.audioSex != audioSex){
        //改变声音；
        try {
          this.$refs.audioPlayer.pause();
          this.$refs.audioPlayer.src=""
          this.audioUrl = await this.fetchAudioStream(audioSex)
          // 使用$nextTick确保DOM更新完成后再尝试播放
          //await this.$nextTick();
          // 重新加载音频，并等待加载完成
          //await this.$refs.audioPlayer.load();
          // 尝试播放音频
          // const playPromise = this.$refs.audioPlayer.play();
          // 捕获播放中的错误
          // playPromise.catch(error => {
          //   console.error("Audio play was rejected: ", error);
          // });
          // 添加error事件监听器，捕获播放过程中的错误
          // this.$refs.audioPlayer.addEventListener('error', (e) => {
          //   console.error('Error playing audio: ', e)
          // })

        } catch (error) {
          console.error('Error fetching or setting up audio: ', error)
        }
      }else if(this.audioSex!=""){
        // 将播放头重置到最初位置
        this.$refs.audioPlayer.currentTime = 0;
        this.$refs.audioPlayer.play();
      }
    },

    async fetchAudioStream(audioSex) {
      const param = {
        text: this.dataAnalysis.assemble,
        sex: audioSex,
      };
      getVoiceFromtext(param)
        .then(response => {
          if (response.status === 200) {
            this.audioUrl = window.URL.createObjectURL(new Blob([response.data]));
            this.$refs.audioPlayer.src = this.audioUrl;
            if(this.audioSex!=""){
              const playPromise = this.$refs.audioPlayer.play();
              // // 捕获播放中的错误
              playPromise.catch(error => {
                console.error("Audio play was rejected: ", error);
              });
            }
            this.audioSex =audioSex;
          } else {
            console.error("Failed to get audio data. Status code: ", response.status);
          }
        })
        .catch(error => {
          console.error("Error fetching audio data: ", error);
        });
    },
    assembleAnalysis(){
      let columnList=[]
      let conditionList=[]
      this.myDataSource.column.forEach(item=>{
        columnList.push(item)
      })
      this.myDataSource.condition.forEach(item=>{
        if(item.whereType=='='){
          item.whereValue=item.whereValue.replace(/\'/g,"")
          item.whereValue="'"+item.whereValue+"'"
        }
        conditionList.push(item)
      })
      const param = {
        columnList: columnList,
        conditionList:conditionList,
        table: this.myDataSource.model.modelCode,
        userId: randNm(6),
        modelId: this.myDataSource.model.modelId,
        dbId: this.myDataSource.model.dbId,
      }
      getAssembleAnalysis(param).then((response) => {
        console.log("response====>",response)
        if(response.data.code==200&&response.data.data){
          let res=response.data.data
          if(response.data.data){
            this.dataAnalysis=res;
            this.nextValList=res.nextValList
            this.nextHbValList=res.nextHbValList
            this.analysisEchcartsFlag=true
          }else {
            this.dataAnalysis= {};
            this.nextValList=[]
            this.nextHbValList=[]
            this.analysisEchcartsFlag=false
          }
        }else {
          this.dataAnalysis= {};
          this.nextValList=[]
          this.nextHbValList=[]
          this.analysisEchcartsFlag=false
        }

        // this.getEcharts();
      })
    },
    getEcharts:function () {
      var vm=this;
      vm.$parent.$parent.goEnd()
      var xList=[];
      var x1List=[];
      var x2List=[];
      var y11List=[];
      var y21List=[];
      this.nextValList.forEach(item=>{
        x1List.push(item.LATN_ID||item.MKT_AREA_ID||item.DEPT_ID||item.DUTY_ZONE_ID)
        y11List.push(item.DATAVAL)
      })
      if(this.nextHbValList&&this.nextHbValList.length>0){
        this.nextHbValList.forEach((item,index)=>{
          // if(index<=y11List.length)
          x2List.push(item.LATN_ID||item.MKT_AREA_ID||item.DEPT_ID||item.DUTY_ZONE_ID)
          y21List.push((item.MOMVAL*100).toFixed(2))
        })
      }
      xList=x1List.length>=x2List.length?x1List:x2List
      let rowNum = 3;
      let max1 = y11List.length != 0 ? Math.max(...y11List) : 1;
      let max2 = y21List.length != 0 ? Math.max(...y21List) : 1;
      let min1 = y11List.length != 0 ? Math.min(...y11List) : 1;
      let min2 = y21List.length != 0 ? Math.min(...y21List) : 1;
      let inter1 = Math.ceil((max1 - min1) / rowNum) || 1;
      let inter2 = Math.ceil((max2 - min2) / rowNum) || 1;
      if (y11List.length != 0 && inter1 != 0) {
        min1 = Math.floor(min1 / inter1) * inter1;
        max1 = Math.ceil(max1 / inter1) * inter1;
      }
      if (y21List.length != 0 && inter2 != 0) {
        min2 = Math.floor(min2 / inter2) * inter2;
        max2 = Math.ceil(max2 / inter2) * inter2;
      }
      if (y21List.length != 0 && y11List.length != 0) {
        let maxNum1 = Math.floor(Math.abs(max1) / inter1)
        let minNum1 = Math.floor(Math.abs(min1) / inter1)
        let maxNum2 = Math.floor(Math.abs(max2) / inter2)
        let minNum2 = Math.floor(Math.abs(min2) / inter2)
        if (maxNum1 > maxNum2) {
          if (maxNum2 == 0) {
            max2 = maxNum1 * inter2 * 1
          } else {
            max2 = maxNum1 * inter2 * ((max2 || 1) / (Math.abs(max2) || 1))
          }
        } else if (maxNum1 < maxNum2) {
          if (maxNum1 == 0) {
            max1 = maxNum2 * inter1 * 1
          } else {
            max1 = maxNum2 * inter1 * ((max1 || 1) / (Math.abs(max1) || 1))
          }
        }
        if (minNum1 > minNum2) {
          if (minNum2 == 0) {
            min2 = minNum1 * inter2 * -1
          } else {
            min2 = minNum1 * inter2 * ((min2 || 1) / (Math.abs(min2) || 1))
          }
        } else if (minNum1 < minNum2) {
          if (minNum1 == 0) {
            min1 = minNum2 * inter1 * -1
          } else {
            min1 = minNum2 * inter1 * ((min1 || 1) / (Math.abs(min1) || 1))
          }
        }
      }

      if (y11List.length == 0) {
        max1 = 1
        min1 = 0
      }
      if (y21List.length == 0) {
        max2 = 1
        min2 = 0
      }

      let yAxis=[
        {
          type:'value',
          name: vm.dataAnalysis.name+(vm.dataAnalysis.dataUnit == null || !vm.dataAnalysis.dataUnit ? "" : "("+vm.dataAnalysis.dataUnit+")"),
          // min: min1,
          // max: max1,
          // interval: inter1,
          splitNumber: rowNum,
          nameTextStyle: {
            color: "#5C7CFF",
            fontSize: this.WidthAdaptive(14),
            padding: this.WidthAdaptive(8),
          },
          alignTicks: true,// 使得0刻度对齐
          axisTick: { show: true },
          axisLabel: {
            textStyle: { color: "#fff", fontSize: this.WidthAdaptive(12) },
          },
          axisLine: {
            show: true,
            lineStyle: { color: "#cccccc", type: "dashed" },
          },
          splitLine: {
            show:true,
            lineStyle: {
              type: "dashed",
              color: "rgba(135,140,147,0.2)",
            },
          },
          boundaryGap: [0, 0.1],
        }
      ]
      let showTop=true
      if (y21List.length>0) showTop=false
      let series=[{
        name: vm.dataAnalysis.name,
        type: "bar",
        barWidth:20,
        smooth: true,
        data: y11List,
        itemStyle:{
          normal:{
            barBorderRadius:[1,1,0,0]
          }
        },
        label: {
          show: showTop, //开启显示
          position: "top", //在上方显示
          formatter: function(value){
            return (y11List[value.dataIndex])
          },
          textStyle: {
            //数值样式
            color: "#5C7CFF",
            fontSize: this.fontSize(0.15),
          },
        },
      }]
      if(y21List.length>0){
        yAxis.push({
          type:'value',
          name: "环比(%)",
          // min: min2,
          // max: max2,
          // interval: inter2,
          splitNumber: rowNum,
          nameTextStyle: {
            color: "#ff675c",
            fontSize: this.WidthAdaptive(14),
            padding: this.WidthAdaptive(8),
          },
          axisTick: { show: true },
          axisLabel: {
            textStyle: { color: "#333333", fontSize: this.WidthAdaptive(12) },
          },
          axisLine: {
            show: true,
            lineStyle: { color: "#cccccc", type: "dashed" },
          },
          splitLine: {
            show:true,
            lineStyle: {
              type: "dashed",
              color: "rgba(135,140,147,0.2)",
            },
          },
          boundaryGap: [0, 0.1],
          position: 'right',
        })
        series.push({
          name: "环比",
          type: "line",
          barWidth:20,
          smooth: true,
          data: y21List,
          yAxisIndex: 1,
          itemStyle:{
            normal:{
              barBorderRadius:[1,1,0,0]
            }
          },
          label: {
            show: true, //开启显示
            position: "top", //在上方显示
            textStyle: {
              //数值样式
              color: "#ff675c",
              fontSize: this.fontSize(0.16),
            },
          },
        })
      }
      let myChart = this.$echarts.init(document.getElementById('echartsAnalysis_'+this.uuid))
      let options = {
        // backgroundColor: "#2e3f5d",
        backgroundColor: {
          type: 'image',
          image: iconpg, // 背景图片的URL
          repeat: 'repeat-x', // 是否平铺，可以是 'repeat-x', 'repeat-y', 'no-repeat'
          size: '100% 100%', // 图片大小，可以是数值或者百分比
          position: 'center center' // 图片位置，可以是数值或者百分比
        },
        color: ["#67ebfa","#ff675c"],
        textStyle: {
          color: "#fff"
        },
        tooltip: {
          show: true,
          trigger: 'axis',
          axisPointer: {
            type: 'shadow'
          },
          formatter: (v) => {
            var html = `<div><span style="color: #666">${v[0].name}</span><br>`
            if((y11List.length-1)>=v[0].dataIndex) {
              html += `<div>
                <span style="color: #666;display: flex;align-items: center">
                  <div style="border-radius: 2px;width: 10px;height: 10px;background:#5C7CFF;margin-right: 7px"></div>
                  ${vm.dataAnalysis.name}&emsp;<span style="color: #333">${v[0].data}${vm.dataAnalysis.dataUnit == null || !vm.dataAnalysis.dataUnit ? "" : vm.dataAnalysis.dataUnit}</span>
                </span>`
            }
            if(this.nextHbValList&&this.nextHbValList.length>0&&(y21List.length-1)>=v[0].dataIndex){
              html+=`<span style="color: #666;display: flex;align-items: center">
                    <div style="border-radius: 1rem;width: 10px;height: 10px;background:#ff675c;margin-right: 7px"></div>
                    环比&emsp;<span style="color: #333">${y21List[v[0].dataIndex]}%</span>
                  </span>`
            }
            html+=`</div>`
            return html
          },
        },
        legend: {
          textStyle: {
            color: "#fff"
          },
          itemHeight: 8,//图例的高度
          itemWidth: 8,
          data:[vm.dataAnalysis.name,'环比']
        },
        dataZoom: [
          {
            // show: false,
            type: 'inside',
            realtime: true,
            startValue: 0,
            endValue: xList.length-1>5?5:xList.length-1,
            bottom: '-25px',
          }
        ],
        grid: {
          left: "10%",
          right: "10%",
          top: "20%",
          bottom: "10%",
          // containLabel: true,
        },
        xAxis: {
          type: 'category',
          axisLabel: {
            textStyle: {
              color: "#fff",
              fontSize: this.WidthAdaptive(12),
            },
            // interval:0,//横轴信息全部显示
            // rotate:10,//-15度角倾斜显示
          },
          axisTick: { show: true },
          axisLine: {
            show: true,
            lineStyle: { color: "#cccccc", type: "dashed" },
          },
          splitLine: {
            show:false,
            lineStyle: {
              type: "dashed",
              color: "rgba(135,140,147,0.2)",
            },
          },
          boundaryGap: true,
          data: xList,
        },
        yAxis: yAxis,
        series: series,
      };

      // 绘制图表
      myChart.setOption(options,true)
      vm.myChart=myChart
    },
    WidthAdaptive:function(res) {
      var windth = window.innerWidth;
      let fontSize = windth / 1920;
      return fontSize * res;
    },
    fontSize:function (res) {
      var docEl = document.documentElement,
        clientWidth = window.innerWidth || document.documentElement.clientWidth || document.body.clientWidth;
      if (!clientWidth) return;
      var fontSize = 100 * (clientWidth / 1920);
      return res * fontSize;
    },
    newQuestion(qu){
      if(this.isClick) this.$emit("fuzzySent",qu)
    },
    redirectUrl(item){
      const param = { targetClientId: item.clientId }
      getRedirectUrl(param).then((response) => {
        let res=response.data.data
        let params="code="+res.code
        if(item.params!=0){
          params+="&"+item.params
        }
        window.open(item.url+"?"+params,"_blank")
      })
    },
    transASC(val) {
      if (val == 'ASC') return '升序'
      return '降序'
    },
    //统计指标编辑
    statisticalEdit(obj, index) {
      const mtl = this.myDataSource.column
      if (index != '') {
        mtl.splice(index - 1, 1, obj)
      } else {
        mtl.push(obj)
      }
      this.myDataSource.column = mtl
      this.afterEdit()
    },
    deleteSondition(index) {
      // debugger
      var mst = this.myDataSource.column
      mst.splice(index, 1)
      this.myDataSource.column=[]
      this.$nextTick(()=>{
        this.myDataSource.column = mst
      })
      this.afterEdit()
    },
    afterEdit() {
      var mtl = this.myDataSource.column
      var fieldCodeArray = mtl.filter((item) => item.fieldClass === 2).map((item) => item.fieldCode)

      this.myDataSource.groupby = fieldCodeArray

      var msort = []
      for (var i = 0; i < mtl.length; i++) {
        var tmtl = mtl[i]
        if (tmtl.fieldClass == 1) {
          var tp = {
            fieldCode: tmtl.selectName ? tmtl.selectName : tmtl.fieldName,
            fieldShowName: tmtl.selectName ? tmtl.selectName : tmtl.fieldName,
            sortType: 'ASC'
          }
          msort.push(tp)
        }
      }
      this.myDataSource.sort = msort
      this.reflashDataSource()
    },
    //刷新数据
    reflashDataSource() {
      let vm=this
      this.$refs.shrikingBox.selectCharts(0)
      const conditionObj = this.myDataSource.condition
      var cstr = ''
      this.quickConditions=[]
      conditionObj.forEach((itemObj,index)=>{
        if(itemObj.fieldCode.startsWith('MONTH_ID')||itemObj.fieldCode.startsWith('DAY_ID')){
          this.quickConditions.push(itemObj)
        }
        if(itemObj.whereValue){
          itemObj.whereValue=itemObj.whereValue.replace(/\'/g,"")
        }else {
          itemObj.whereValue="NULL"
        }
        var nameVs = itemObj.whereValueName ? itemObj.whereValueName : itemObj.whereValue
        let nameV = ""
        if(nameVs){
          // nameV=nameVs.replace("'", '').replace("'", '')
          nameV=nameVs.replace(/\'/g,"")
        }else {
          itemObj.whereValue="NULL"
          nameV="NULL"
        }
        cstr += itemObj.fieldName + transCodeToStr(itemObj.whereType) + nameV
        if (index < conditionObj.length - 1) {
          cstr += '、'
        }
      })
      //重新拼装快速提问条件
      if(this.quickConditions.length==0){
        this.quickCondition={};
      }else if(this.quickConditions.length==1){
        this.quickCondition.fieldCode=this.quickConditions[0].fieldCode
        this.quickCondition.fieldName=this.quickConditions[0].fieldName
        this.quickCondition.whereType=this.quickConditions[0].whereType
        if(this.quickConditions[0].whereType!='IN'&&this.quickConditions[0].whereType!='BETWEEN'){
          this.quickCondition.whereValue=this.quickConditions[0].whereValue
          this.quickCondition.isArr=false
        }else{
          this.quickCondition.whereValue=[]
          this.quickCondition.isArr=true
        }
      }else if(this.quickConditions.length==2){
        this.quickCondition.fieldCode=this.quickConditions[0].fieldCode
        this.quickCondition.fieldName=this.quickConditions[0].fieldName
        this.quickCondition.whereValue=[this.quickConditions[0].whereValue,this.quickConditions[1].whereValue]
        this.quickCondition.isArr=true
      }
      if(this.myDataSource.maxPeriod){
        if(this.myDataSource.model.dateType=="M"){
          this.myDataSource.maxPeriodFormat=moment(this.myDataSource.maxPeriod).format("YYYY年MM月")
        }else {
          this.myDataSource.maxPeriodFormat=moment(this.myDataSource.maxPeriod).format("YYYY年MM月DD日")
        }
      }
      if(this.myDataSource.minPeriod&&this.myDataSource.maxPeriod){
        this.quickCondition.disabledDate=(time) => {
          let startTime,endTime;
          if(this.myDataSource.model.dateType=="M"){
            startTime=moment(this.myDataSource.minPeriod, 'YYYYMM').toDate();
            endTime=moment(this.myDataSource.maxPeriod, 'YYYYMM').toDate();
          }else {
            startTime=moment(this.myDataSource.minPeriod, 'YYYYMMDD').toDate();
            endTime=moment(this.myDataSource.maxPeriod, 'YYYYMMDD').toDate();
          }
          if(!endTime||!startTime){
            return ""
          }else {
            return time.getTime() > endTime.getTime()||time.getTime() < startTime.getTime()
          }
        }
      }
      this.conditionDes = cstr
      const columnObj = this.myDataSource.column
      if (columnObj && columnObj.length > 0) {
        const columnList = columnObj.filter((item) => {
          return item.fieldClass==1
        })
        const columnNames = columnList.map((item) => item.fieldName)
        // const columnNames = columnObj.map((item) => item.fieldName)
        this.columnDes = columnNames.join('、')
      }

      const groupObj = this.myDataSource.groupby

      if (groupObj && groupObj.length > 0) {
        var matchingFieldNames = columnObj
          .filter((item) => groupObj.includes(item.fieldCode))
          .map((item) => item.fieldName)
        this.groupbyDes = matchingFieldNames.join('、')
      }

      var sortstr = ''
      const sortObj = this.myDataSource.sort
      if (sortObj) {
        for (var j = 0; j < sortObj.length; j++) {
          var sitem = sortObj[j]
          var sitemCode = sitem.fieldShowName

          sortstr += sitemCode + transCodeToStr(sitem.sortType)
          if (j < sortObj.length - 1) {
            sortstr += '、'
          }
        }
        this.sortDes = sortstr
      }
      //处理fuzzyTexts
      this.fuzzyTexts=this.myDataSource.fuzzyTexts?this.myDataSource.fuzzyTexts:[]
      this.indicatorTexts=this.myDataSource.indicatorTexts?this.myDataSource.indicatorTexts:[]
      // this.fuzzyTexts=['你是谁你是谁你是谁你是谁你是谁？','你是谁你是谁你是谁你是谁你是谁？','你是谁你是谁你是谁你是谁你是谁？',
      //   '你是谁你是谁你是谁你是谁你是谁？','你是谁你是谁你是谁你是谁你是谁？','hihihihihihihihihihihi']
      //处理表格数据（合计、添加单位）
      let pcReportUrls=[]
      // console.log(this.myDataSource,'this.myDataSource');
      var newCresult = this.myDataSource.result
      newCresult.periodResult = this.myDataSource.periodResult
      newCresult.latnResult = this.myDataSource.latnResult
      const cresult = newCresult
      this.myDataSource.column.forEach((item,index)=>{
        if(item.fieldClass===1){
          this.sumCol.push(index)
        }
        //处理相关指标数据
        // var a="移动用户"
        // if(a){
        if(item.pcReportUrls){
          //报表名称1##连接地址1##参数##clientId1&&报表名称2##连接地址2##参数##clientId2 //如果没有是0
          var pcReportData=item.pcReportUrls.split("&&")
          // var pcReportData=a.split("&&")
          if(pcReportData.length>0){
            pcReportData.forEach(prcItem=>{
              var prcList=prcItem.split("##")
              var em={
                name:prcList[0],
                url:prcList[1],
                params:prcList[2],
                clientId:prcList[3]
              }
              pcReportUrls.push(em)
            })
          }
        }
        vm.pcReportUrls = Array.from(new Set(pcReportUrls.map((obj) => JSON.stringify(obj)))).map((strObj) => JSON.parse(strObj));

        vm.myDataSource.result.header.forEach(itemHeader=>{
          if(itemHeader.column==item.selectName){
            this.units[itemHeader.column]=item.dataUnit == null || !item.dataUnit ? '' : item.dataUnit
            this.fieldcolumns[itemHeader.column]=item
            // itemHeader.fieldName=itemHeader.fieldName+"("+item.dataUnit+")"
          }
        })
      })
      const cheaders = cresult.header
      for (var i = 0; i < cheaders.length; i++) {
        var hobj = cheaders[i]
        var foundhobj = columnObj.find(function (item) {
          return item.selectName === hobj.column
        })
        if (foundhobj && foundhobj.fieldClass == 2) {
          hobj.valueT = 'N'
        } else {
          hobj.valueT = 'T'
        }
      }
      this.chartDataResult = cresult
      if (this.myDataSource.phySql) {
        this.currentSql = this.myDataSource.phySql
      } else {
        const contentRewrite = this.myDataSource.contentRewrite
        const sqlObj = contentRewrite[contentRewrite.length - 1]
        this.currentSql = sqlObj.answer
      }
    },
    addConditionEdit(obj) {
      this.myDataSource.condition.push(obj)
      this.setDisabledOption(this.allOption)
    },
    conditionEdit(vidx, obj) {
      // vidx就是无为的代参
      this.wValue = vidx
      if (!obj) {
        var mst = this.myDataSource.condition
        mst.splice(vidx, 1)
        this.myDataSource.condition=[]
        this.$nextTick(()=>{
          this.myDataSource.condition=mst
        })
      } else {
        this.myDataSource.condition[vidx] = obj
      }
      this.setDisabledOption(this.allOption)
    },
    queryTableValueAc() {
      if (this.myDataSource && this.myDataSource.model && this.myDataSource.model.modelId) {
        var gmodelId = this.myDataSource.model.modelId
        const param = { modelId: gmodelId }
        getDataFromTb(param).then((response) => {
          const res = response.data.data

          this.fiterOption = res.filter(function (item) {
            return item.isItem === 1 || item.fieldType === 3
          })
          this.setDisabledOption(res)
        })
      }
    },
    setDisabledOption(optionList){
      var level=0
      var conditionList=this.myDataSource.condition
      conditionList.forEach(item=>{
        var temp=this.level_list_option_1.find(itemLevel=>{return item.fieldCode==itemLevel.label})
        if(temp&&temp.level>level){
          level=temp.level
        }
      })
      this.allOption=[]
      optionList.forEach(item=>{
        var temp=this.level_list_option_1.find(itemLevel=>{return item.fieldCode==itemLevel.label})
        if(temp&&temp.level<=level){
          item.disabled=true
        }else {
          item.disabled=false
        }
        this.allOption.push(item)
      })
      // this.allOption = optionList
    },
    translateTname(obj) {
      return obj.fieldName + transCodeToStr(obj.whereType) + obj.whereValue
    },
    async dropChangeAct(vale) {
      if (vale === 'd') {
        this.loading=true
        await this.$refs.charRef.exportExcel()
      } else if (vale === 'a') {
        this.$refs.watchsqlref.openDialog(this.currentSql)
      } else if (vale === 'e') {
        this.$refs.watchuseref.openDialog()
      }
    },
    callback(e) {
      // if (err) throw err;
      console.log('Excel文件已成功保存------->',e);
      this.loading=e
    },
    //sql执行
    watchSqlExe() {
      const psql = this.currentSql
      const tableId = this.myDataSource.model.dbId
      // debugger
      const parm = { dbId: tableId, sql: psql }
      postSqlFromSQL(parm)
        .then((response) => {
          const res = response.data.data
          this.myDataSource = res
          this.reflashDataSource()
          //查询表元数据
          this.queryTableValueAc()
        })
        .catch((err) => {
          this.$message.error(err)
        })
    },
    showEdit() {
      this.flag1 = !this.flag1
    },
    changeCharts(index) {
      this.analysisFlag=false
      this.lsText=""
      switch (index) {
        case 0:
          self.chType = 'table'
          break
        case 1:
          self.chType = 'bar'
          break
        case 2:
          self.chType = 'columnbar'
          break
        case 3:
          self.chType = 'line'
          break
        case 4:
          self.chType = 'pie'
          break
        default:
          self.chType = 'radar'
          break
      }

      const childComponent = this.$refs.charRef
      const rlt = this.myDataSource.result
      const rltdata = rlt.data
      // 调用子组件的方法
      if (childComponent && rltdata.length >= 1) {
        childComponent.switchChart(self.chType)
      }
    },
    quickEmitData(){
      let startDate=""
      let endDate=""
      let singleDate=""
      if(this.quickCondition.isArr&&this.quickCondition.fieldCode.startsWith("MONTH_ID")){
        startDate=moment(this.quickCondition.whereValue[0]).format("YYYYMM")
        endDate=moment(this.quickCondition.whereValue[1]).format("YYYYMM")
        let new_1={
          fieldCode: this.quickCondition.fieldCode,
          fieldName: this.quickCondition.fieldName,
          fieldType: 1,
          isItem: 0,
          whereType: ">=",
          whereValue: startDate,
          whereValueName: startDate,
        }
        let new_2={
          fieldCode: this.quickCondition.fieldCode,
          fieldName: this.quickCondition.fieldName,
          fieldType: 1,
          isItem: 0,
          whereType: "<=",
          whereValue: endDate,
          whereValueName: endDate,
        }
        this.quickConditions=[]
        this.quickConditions.push(new_1)
        this.quickConditions.push(new_2)
      }else if(this.quickCondition.isArr&&this.quickCondition.fieldCode.startsWith("DAY_ID")){
        startDate=moment(this.quickCondition.whereValue[0]).format("YYYYMMDD")
        endDate=moment(this.quickCondition.whereValue[1]).format("YYYYMMDD")
        let new_1={
          fieldCode: this.quickCondition.fieldCode,
          fieldName: this.quickCondition.fieldName,
          fieldType: 1,
          isItem: 0,
          whereType: ">=",
          whereValue: startDate,
          whereValueName: startDate,
        }
        let new_2={
          fieldCode: this.quickCondition.fieldCode,
          fieldName: this.quickCondition.fieldName,
          fieldType: 1,
          isItem: 0,
          whereType: "<=",
          whereValue: endDate,
          whereValueName: endDate,
        }
        this.quickConditions=[]
        this.quickConditions.push(new_1)
        this.quickConditions.push(new_2)
      }else {
        singleDate=this.quickCondition.whereValue
        this.quickConditions[0].whereValue=singleDate
        this.quickConditions[0].whereValueName=singleDate
      }
      let newConditionList=[]
      // newConditionList.concat(this.quickConditions)
      this.myDataSource.condition.forEach(item=>{
        if(item.fieldCode!=this.quickCondition.fieldCode){
          newConditionList.push(item)
        }
      })
      Array.prototype.push.apply(newConditionList,this.quickConditions);
      this.myDataSource.condition=[]
      Array.prototype.push.apply(this.myDataSource.condition,newConditionList);
      this.myDataSource.condition.forEach((item,index)=>{
        if(index!=0){
          item.connector=" AND "
        }else {
          item.connector=""
        }
        item.whereValue=item.whereValue.replace(/\'/g,"")
      })
      this.$nextTick(()=>{
        this.reflashDataSource()
        this.saveEdit()
        this.$nextTick(()=>{
          this.$refs.popoverCompRef.forEach((item,index)=>{
            item.init()
          })
          this.assembleAnalysis();
        })
      })
    },
    // 点击确定触发的方法
    saveEdit() {
      this.tab_loading=true
      this.flag1 = this.flag2 = this.flag3 = this.flag4 = false
      let newMyDataSource=JSON.parse(JSON.stringify( this.myDataSource))
      newMyDataSource.condition.forEach(item=>{
        item.whereValue=item.whereValue.replace(/\'/g,"")
        if(item.fieldType==1&&item.whereType=="="){
          item.whereValue="'"+item.whereValue+"'"
        }
        if(item.fieldType==1&&item.whereType=="IN"){
          item.whereValue=item.whereValue.replace(/\'/g,"")
          var sp=item.whereValue.split(",")
          var newWhereValue="";
          sp.forEach(item=>{
            if(newWhereValue) newWhereValue+=",'"+item+"'"
            else newWhereValue+="'"+item+"'"
          })
          item.whereValue=newWhereValue
        }
        if(item.fieldType==1&&item.whereType=="BETWEEN"){
          item.whereValue=item.whereValue.replace(/\'/g,"")
          var sp=item.whereValue.split(",")
          var newWhereValue="";
          sp.forEach(item=>{
            if(newWhereValue) newWhereValue+=item
            else newWhereValue+=item +" AND "
          })
          item.whereValue=newWhereValue
        }
      })
      const param = newMyDataSource
      param.staffAccount = this.orgsObj.staffAccount
      param.orgId = this.orgsObj.orgId
      param.orgName = this.orgsObj.orgName
      param.orgLeave = this.orgsObj.orgLeave
      param.userId = randNm(6),
      // this.$emit("dataBySql",param)
      getValFromSQL(param).then((response) => {
        if (response.data.code != 200) {
          ElMessage(response.data.message)
          return
        }
        const res = response.data.data
        if (res.column) {
          this.myDataSource = res
          this.reflashDataSource()
          //查询表元数据
          this.queryTableValueAc()
        } else {
          this.$message.error(res)
        }
        this.tab_loading=false
      })
    },
    cancleEdit() {
      this.$refs.popoverCompRef.forEach(item=>{
        item.closePopover()
      })
      this.$refs.popoverCompAddRef.closePopover()
      this.flag1 = this.flag2 = this.flag3 = this.flag4 = false

      // this.myDataSource = { ...this.dataSource };

      // debugger;
    },
    closeOtherPo(sIndex){
      this.$refs.popoverCompRef.forEach((item,index)=>{
        if(sIndex!=0&&!sIndex) item.closePopover()
        else if(sIndex!=index){
          item.closePopover()
          this.$refs.popoverCompAddRef.closePopover()
        }
      })
    },
    // popoverCompAddRef
    changeActItem(val) {
      var vm=this;
      if (val == 0 || val == 1) {
        if(val == 0){
          let evaluateParams={sessionId:this.logSessionId,evaluateStatus:'1',evaluateType:'',evaluate:''}
          saveEvaluateInfo(evaluateParams).then((res) => {
            ElMessage({
              showClose: true,
              message: '评价成功！',
              type: 'success',
            })
            this.$refs.shrikingBox.activeIcon=1
          })
        }else {
          this.$refs.suggestcompref.openDialog()
        }
      }else if(val == 2&&this.analysisEchcartsFlag){
        $("#echartsAnalysis_"+vm.uuid).css("width","100%")
        $("#echartsAnalysis_"+vm.uuid).css("height","0px")
        $("#echartsAnalysis_"+vm.uuid).css("background","#fff")
        if(vm.myChart) vm.myChart.clear();
        this.analysisFlag=true
        this.lsText=""
        let ls=this.dataAnalysis.assemble.length;
        this.audioSex=""
        this.audioUrl=""
        this.changeVoice(2);
        for (var i = 0; i < ls; i++) {
          (function(index) {
            setTimeout(function() {
              vm.lsText+=vm.dataAnalysis.assemble.charAt(index)
            }, index * 50); // 间隔时间是index乘以1000毫秒
          })(i);
        }

        setTimeout(function() {
          $("#echartsAnalysis_"+vm.uuid).css("width","100%")
          $("#echartsAnalysis_"+vm.uuid).css("height","250px")
          $("#echartsAnalysis_"+vm.uuid).css("background","#fff")
          vm.$nextTick(()=>{
            vm.getEcharts()
            vm.analysisEchcartsFlag=true
          })
        }, ls * 50);

      }
      console.log('选择的功能按键是' + val)
    }
  },
  computed: {}
}
</script>

<style lang="scss" scoped>
//@import './index.css';

.bview {
  padding: 5px 10px;
}

.grayc {
  color: #ff9297;
}

.btnview {
  padding: 5px 10px;
  margin-right: 5px;
}

.f13 {
  font-size: 13px;
}

.el-date-editor.el-input,
.el-date-editor.el-input__inner {
  width: auto;
}

</style>
